//
//  HFMainTabbarController.swift
//  HFWeChat
//
//  Created by 黄来峰 on 16/4/17.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class HFMainTabbarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        //初始化tabar
        let tabbar = HFTabbar()
        
        setValue(tabbar, forKey: "tabBar")
        
        //设置tabBar的代理
        tabbar.tabbarDelegate = self
     
        addChildViewController(HFHomeTableViewController(), imageName: "tabbar_home", title: "主页")
        addChildViewController(HFMessageController(), imageName: "tabbar_message_center", title: "消息")
        addChildViewController(HFDiscoverController(), imageName: "tabbar_discover", title: "发现")
        addChildViewController(HFProfileController(), imageName: "tabbar_profile", title: "我的")
       setUpAppTintColor()
   
    }

    func addChildViewController(childController: UIViewController,imageName: String,title: String) {
        childController.tabBarItem.title = title
        childController.tabBarItem.image = UIImage(named: imageName)
        childController.tabBarItem.selectedImage  = UIImage(named: "\(imageName)_selected")
        //设置子控制器的标题
        childController.title = title
        
        //将子控制器设置为根控制器
        addChildViewController(UINavigationController(rootViewController: childController))
        
        
    }
    //设置app全局的颜色
    func setUpAppTintColor(){
        
        UITabBar.appearance().tintColor = ThemeColor
        UINavigationBar.appearance().tintColor = ThemeColor
        
    }

    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
 //MARK -代理方法的实现不能再自身实现，必须在其分类中实现
     //MARK -composeButton的点击事件
    
    
}

extension HFMainTabbarController:HFTabBarDelegate{
    func presentViewController(){
        
        print("某个按钮被点击了")
    
    }
}

